using System;
using System.Runtime.CompilerServices;

namespace Hsenl {
    [Serializable]
    public struct Uint2 : IEquatable<Uint2> {
        public uint x;
        public uint y;

        public uint this[int index] {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get {
                return index switch {
                    0 => this.x,
                    1 => this.y,
                    _ => throw new IndexOutOfRangeException("vector idx invalid" + index)
                };
            }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            set {
                switch (index) {
                    case 0:
                        this.x = value;
                        break;
                    case 1:
                        this.y = value;
                        break;
                    default:
                        throw new IndexOutOfRangeException("vector idx invalid" + index);
                }
            }
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public Uint2(uint x, uint y) {
            this.x = x;
            this.y = y;
        }
        
        public bool Equals(Uint2 other) {
            return this.x == other.x && this.y == other.y;
        }

        public override bool Equals(object obj) {
            return obj is Uint2 other && this.Equals(other);
        }

        public override int GetHashCode() {
            return HashCode.Combine(this.x, this.y);
        }
    }
}